﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceManager.Facade.EnterpriseManagementClasses;
using System.ServiceManager.Facade.EnterpriseManagementObjects;
using System.Text;
using Microsoft.EnterpriseManagement.Common;
using Microsoft.EnterpriseManagement.Configuration;
 

namespace System.ServiceManager.Facade
{
    public static class SCSMChangeRequest
    {

        public static ManagementPackClass ChangeRequestClass = System_WorkItem_ChangeRequestInfo.GetManagementPackClass();


        public static EnterpriseManagementObjectProjection CreateChangeRequest ()
        {
            return new EnterpriseManagementObjectProjection(SCSMServer.CurrentManagementGroup, ChangeRequestClass);
        }

        //public static EnterpriseManagementObjectProjection GetChangeRequest (string id)
        //{

        //    var builder = new CriteriaBuilder();

        //    builder.AddReferences(SCSMServer.SystemWorkItemChangeRequestLibrary.Name, "ChangeRequest");

        //    const string property = "$Target/Property[Type='ChangeRequest!System.WorkItem.ChangeRequest']/Id$";

        //    var criteria = builder.CreateSimpleCriteria(SCSMServer.CommonTypeProjections.ChangeRequestProjection, property, id);

        //    return SCSMServer.GetObjectProjectionReader(criteria, ObjectQueryOptions.Default).FirstOrDefault();


        //}

    //public static 
    //    IObjectProjectionReader<EnterpriseManagementObject> GetChangeRequestReader
    //    (string
    //    id)
    //{

    //    var builder = new CriteriaBuilder();
    //    builder.AddReferences(SCSMServer.SystemWorkItemChangeRequestLibrary.Name, "ChangeRequest");

    //    const string property = "$Target/Property[Type='ChangeRequest!System.WorkItem.ChangeRequest']/Id$";

    //    var criteria = builder.CreateSimpleCriteria(SCSMServer.CommonTypeProjections.ChangeRequestProjection,
    //                                                property, id);

    //    return SCSMServer.GetObjectProjectionReader(criteria, ObjectQueryOptions.Default);


    //}

    }
}

